public class test7 {
    //获取一个数二进制所有偶数位和奇数位，输出二进制数列
    public static void main(String[] args) {
        int num=17;
        String binaryString=Integer.toBinaryString(num);

        StringBuilder evenBits=new StringBuilder();
        StringBuilder oddBits=new StringBuilder();

        for (int i=0;i<binaryString.length();i++){

            char bit=binaryString.charAt(i);

            if (i%2==0){
                evenBits.append(bit);
            }else {
                oddBits.append(bit);
            }
        }
        System.out.println("Original binary"+binaryString);
        System.out.println("Even position binary"+evenBits.toString());
        System.out.println("odd position binary"+oddBits.toString());

    }
}
